package com.insurance.web;

import java.util.List;
import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;

import com.insurance.bean.Agent;
import com.insurance.bean.Proxy;
import com.insurance.service.ProxyService;
import com.insurance.util.PageBean;


public class ProxyAction {
	@Resource ProxyService proxyService;
	private List<Proxy> proxys;
	private Proxy proxy;
	private Integer id;
	private Integer type;
	private PageBean page;
	
	public PageBean getPage() {
		return page;
	}
	public void setPage(PageBean page) {
		this.page = page;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}

	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Proxy getProxy() {
		return proxy;
	}
	public void setProxy(Proxy proxy) {
		this.proxy = proxy;
	}
	

	/**
	 * proxy Home 
	 */
	public String index(){
		this.proxys = this.proxyService.getProxys();
		return "index";
	}
	
	/**
	 * 产品列表
	 */
	public String list(){
		this.proxys = proxyService.getProxys();
		return "list";
	}
	

	/**
	 * 
	 * 显示单个产品
	 */
	public String showProxy(){
		this.proxy = this.proxyService.getProxy(this.id);
		return "show";
	}
	/**
	 * 
	 * add a proxy 
	 */
	public String add(){
		Agent agent = (Agent)ServletActionContext.getRequest().getSession().getAttribute("agent");
		proxy.setAgentId(agent.getId());
		this.proxyService.save(this.proxy);
		return "success";
	}
	
	public List<Proxy> getProxys() {
		return proxys;
	}

	public void setProxys(List<Proxy> proxys) {
		this.proxys = proxys;
	}
	
}
